﻿using System;
using System.Collections.Generic;

namespace YummyGame.Framework
{
    public enum ActionRunState
    {
        Success,
        Running,
        Failure
    }
    public abstract class SkillAction:IPoolObject,IDisposable
    {
        public SkillExecuter Executer;
        public SkillActionPrototype Prototype;
        public SkillOwner Owner => Executer.Owner;
        public abstract void Reactive();
        public abstract ActionRunState Excute();
        public abstract ActionRunState Run();
        public abstract void Dispose();

        public void OnEnable()
        {
            
        }

        public void OnDisable()
        {
            Executer = null;
            Prototype = null;
        }

        protected Expression ParseRuntimeExpression(Expression expression)
        {
            Expression result = (Expression)expression.Clone();
            result.RebindContext(Executer.Runtime.m_context);
            return result;
        }

        protected void SetVariable(string key,float value)
        {
            Executer.Runtime.SetVariable(key, value);
        }
    }
}
